tywx.EncodeDecode = {
    base64Encode: function (e) {
        for (var t, n, o, i, a, r, s, l = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", c = "", d = 0, u = (e = tywx.EncodeDecode.utf8Encode(e)).length; d < u;) i = (t = e.charCodeAt(d++)) >> 2,
            a = (3 & t) << 4 | (n = e.charCodeAt(d++)) >> 4, r = (15 & n) << 2 | (o = e.charCodeAt(d++)) >> 6,
            s = 63 & o, isNaN(n) ? r = s = 64 : isNaN(o) && (s = 64), c = c + l.charAt(i) + l.charAt(a) + l.charAt(r) + l.charAt(s);
        return c;
    },
    base64Decode: function (e) {
        for (var t, n, o, i, a, r, s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", l = 0, c = (e = e.replace(/[^A-Za-z0-9\+\/\=]/g, "")).length, d = []; l < c;) t = s.indexOf(e.charAt(l++)) << 2 | (i = s.indexOf(e.charAt(l++))) >> 4,
            n = (15 & i) << 4 | (a = s.indexOf(e.charAt(l++))) >> 2, o = (3 & a) << 6 | (r = s.indexOf(e.charAt(l++))),
            d.push(t), 64 != a && d.push(n), 64 != r && d.push(o);
        return d;
    },
    utf8Encode: function (e) {
        for (var t = "", n = 0, o = (e = e.replace(/\r\n/g, "\n")).length; n < o; n++) {
            var i = e.charCodeAt(n);
            i < 128 ? t += String.fromCharCode(i) : i > 127 && i < 2048 ? (t += String.fromCharCode(i >> 6 | 192),
                t += String.fromCharCode(63 & i | 128)) : (t += String.fromCharCode(i >> 12 | 224),
                t += String.fromCharCode(i >> 6 & 63 | 128), t += String.fromCharCode(63 & i | 128));
        }
        return t;
    },
    utf8Decode: function (e) {
        for (var t, n = "", o = 0, i = t = 0, a = e.length; o < a;) (i = e[o]) < 128 ? (n += String.fromCharCode(i),
            o++) : i > 191 && i < 224 ? (t = e[o + 1], n += String.fromCharCode((31 & i) << 6 | 63 & t),
            o += 2) : (t = e[o + 1], c3 = e[o + 2], n += String.fromCharCode((15 & i) << 12 | (63 & t) << 6 | 63 & c3),
            o += 3);
        return n;
    }
}
